package webapp.mvc.services;

import com.zoowii.jpa_utils.extension.Paginator;
import me.chanjar.weixin.mp.api.WxMpService;
import webapp.mvc.controllers.forms.RegisterForm;
import webapp.mvc.exceptions.UserException;
import webapp.mvc.models.RoleEntity;
import webapp.mvc.models.UserEntity;
import webapp.mvc.models.WechatPushContentEntity;
import webapp.mvc.models.WechatPushHistoryEntity;

import java.util.List;

public interface IUserService {
    UserEntity checkUserAuth(String username, String password) throws UserException;
    UserEntity registerUser(RegisterForm registerForm) throws UserException;
    UserEntity changePassword(String userId, String password) throws UserException;
    UserEntity findByUsername(String username);
    UserEntity findById(String id);

    UserEntity findUserByWechatOpenId(String openId);

    UserEntity findOrCreateUserByWechatOpenId(WxMpService wxMpService, String openId) throws UserException;

    UserEntity createWechatUserBinding(String openId, String nickName, int gender, String phone) throws UserException;

    void initRoles();

    List<RoleEntity> getAllRoles();

    RoleEntity getAdminRole();

    RoleEntity getShopOwnerRole();

    RoleEntity getPushAdminRole();

    RoleEntity getShopCheckerRole();

    RoleEntity getProductCheckerRole();

    void addRoleToUser(String userId, String roleId);

    void removeRoleFromUser(String userId, String roleId);

    List<RoleEntity> getRolesOfUser(String userId);

    List<UserEntity> getUsers(Paginator paginator);

    WechatPushContentEntity saveWechatPushContent(String contentId, String title, String jsonStr);

    WechatPushHistoryEntity saveWechatPushHistory(String contentId, String userId);

    List<WechatPushContentEntity> getWechatPushContents(Paginator paginator);

    WechatPushContentEntity findWechatPushContentById(String id);

    List<WechatPushHistoryEntity> getWechatPushHistories(String contentId);

    void deleteWechatPushContent(String contentId);
}
